package com.llc.mall.user.interfaces.multishop;

import com.llc.mall.user.application.command.service.UserAppService;
import com.llc.mall.user.application.query.service.UserQueryService;
import com.llc.mall.user.interfaces.vo.UserVo;
import com.llc.mall.common.database.qo.BasePageQo;
import com.llc.mall.common.database.vo.PageVO;
import com.llc.mall.user.application.query.dto.UserDTO;
import com.llc.mall.common.core.response.ServerResponseEntity;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import jakarta.validation.Valid;

@Tag(name = "店铺-用户表")
@RequestMapping("/m/user")
@RestController
public class MultiUserController {

    @Resource
    private UserAppService userAppService;

    @Resource
    private UserQueryService userQueryService;

	@GetMapping("/page")
	@Operation(summary = "获取用户表列表" , description = "分页获取用户表列表")
	public ServerResponseEntity<PageVO<UserVo>> page(@Valid BasePageQo pageDTO) {
        PageVO<UserVo> result = userQueryService.page(pageDTO);
		return ServerResponseEntity.success(result);
	}

	@GetMapping
    @Operation(summary = "获取用户表" , description = "根据userId获取用户表")
    public ServerResponseEntity<UserVo> getByUserId(@RequestParam Long userId) {
        UserVo vo = userQueryService.detail();
        return ServerResponseEntity.success(vo);
    }

    @PutMapping
    @Operation(summary = "更新用户表" , description = "更新用户表")
    public ServerResponseEntity<Void> update(@Valid @RequestBody UserDTO userDTO) {
        userAppService.modifyUser(null);
        return ServerResponseEntity.success();
    }

}
